<template>
	<div  :style="{width: widths + 'px',height: heights + 'px'}">
	<Row class="login">
		<Row>
			<div class="content">
				<Row class="logo">mole<strong style="color:#F13E3F">molde</strong></Row>
				<Form ref="loginInfo" :model="loginInfo" :rules="ruleInline">
					<Form-item prop="user">
						<Input type="text" v-model="loginInfo.user" placeholder="请输入用户名" >
						<Icon type="ios-person-outline" slot="prepend" style="font-size: 22px;"></Icon>
						</Input>
					</Form-item>
					<Form-item prop="password">
						<Input type="password" v-model="loginInfo.password" placeholder="请输入密码" @on-enter="login">
						<Icon type="ios-locked-outline" slot="prepend" style="font-size: 22px;"></Icon>
						</Input>
					</Form-item>
					<Row>
					</Row>
					<Form-item>
						<Button type="primary" @click="login('loginInfo')" class="w100">登录</Button>
					</Form-item>
				</Form>
			</div>
		</Row>
	</Row>
</div>
</template>

<script>
	export default {
		data() {
			return {
				//记住密码
				 single: false,
				//宽高
				heights: document.documentElement.clientHeight,
                widths: document.documentElement.clientWidth,
				isShow: false,
				loginInfo: {
					user: '',
					password: '',
				},
				categorys: [],
				remember: false,
				ruleInline: {
					user: [{
						required: true,
						message: '请填写用户名',
						trigger: 'blur'
					}],
					password: [{
							required: true,
							message: '请填写密码',
							trigger: 'blur'
						},
						{
							type: 'string',
							min: 5,
							message: '密码长度不能小于5位',
							trigger: 'blur'
						}
					],
				
				}
			}
		},
		mounted() {
			
		},
		methods: {
			
		
			login: function() {
						let user = {
							fusername: this.loginInfo.user,
							fpassword: this.loginInfo.password,
						};
						this.$http.post(this.url + 'login',user).then(response => {
							let isOk = response.data;
							if(isOk.success) {
								//webtoken
								console.info(isOk.obj)
								localStorage.webtoken = isOk.obj;
								this.$router.push("/home")
								this.$Message.success(isOk.msg);
							} else {
								this.$Message.error(isOk.msg);
							}
						}, response => {
							
						});
			},
			 
		}
	}
</script>